﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AgentSystem.AgentBaseFunctionality.Data
{
    /// <summary>
    /// Agent Singleton. 
    /// Used to specify the BaseAgent implementation to the service.
    /// </summary>
    public class ActiveAgent
    {
        /// <summary>
        /// Singleton Instance
        /// </summary>
        private static IAgent Agent = null;

        private static object syncLock = new Object(); 
        /// <summary>
        /// Private Class
        /// </summary>
        private ActiveAgent() { }

        /// <summary>
        /// Sets the active agent.
        /// </summary>
        /// <param name="agent">IAgent implementation.</param>
        public static void SetActiveAgent(IAgent agent)
        {
            Agent = agent;
        }

        /// <summary>
        /// Get Acrive Agent Instance
        /// </summary>
        public static IAgent Instance
        {
            get
            {
                if (Agent == null)
                {
                    throw new ArgumentNullException("The Active Agent has not been set.");
                }
                return Agent;
            }
        }

    }
}
